// 文件名可改为 OpenApiConfig.java
package com.guigu.ssyx.common.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        // 自定义服务器
        Server server = new Server();
        server.setUrl("http://localhost:8080");
        server.setDescription("开发环境");

        Contact contact = new Contact()
                .name("atguigu")
                .email("guigu@example.com")
                .url("http://guigu.com");

        Info info = new Info()
                .title("尚上优选 API 文档")
                .version("1.0")
                .description("网站与后台系统接口文档")
                .contact(contact)
                .license(new License().name("Apache 2.0").url("http://springdoc.org"));

        return new OpenAPI()
                .servers(Arrays.asList(server))
                .info(info);
    }
}